/**
 * #### 一元函数接口
 */
export type UnaryFunc = (x: number) => number
export type BinaryFunc = (x: number, y: number) => number
export type TernaryFunc = (x: number, y: number, z: number) => number
export type UnionFunc = UnaryFunc | BinaryFunc | TernaryFunc

abstract class Solve {
  static readonly TOLERANCE = 1e-6
  static readonly MAX_ITERATIONS = 100
  static readonly EPSILON = 1e-10
  originalUnaryFunc: UnaryFunc | null = null
  originalBinaryFunc: BinaryFunc | null = null
  originalTernaryFunc: TernaryFunc | null = null
  //   target: number
  constructor(originalFunc: UnionFunc) {
    if (originalFunc.length === 1) {
      this.originalUnaryFunc = originalFunc as UnaryFunc
    } else if (originalFunc.length === 2) {
      this.originalBinaryFunc = originalFunc as BinaryFunc
    } else {
      this.originalTernaryFunc = originalFunc as TernaryFunc
    }
  }
  abstract unarySolve(
    target: number,
    initialGuess: number | [number, number],
  ): number
}
export default Solve
